<!-- 
    数组求和以及平均值
    求数组[2,6,1,7]里面所有元素的和以及平均值
 -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var arr = [2, 6, 1, 7, 4];
        var sum = 0;
        var average = 0;
        for (var i = 0; i < arr.length; i++) {
            sum += arr[i];
        }

        average = sum / arr.length;
        console.log(sum, average);  //求平均值
        //输出多个值，以逗号分隔。

    </script>
</head>

<body>

</body>

</html>